<?php
// namespace App\Admin\Controllers;

// use App\Admin\Models\AdminUsers;
// use App\Admin\Models\Setting;
// use Illuminate\Http\Request;
// use Encore\Admin\Controllers\AdminController;
// use Encore\Admin\Form;
// use Encore\Admin\Grid;
// use Encore\Admin\Facades\Admin;
// use Encore\Admin\Show;
// use Illuminate\Support\Facades\Storage;
// use Illuminate\Support\Facades\Auth;
// use function foo\func;
// class QrcodeController extends AdminController
namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\Dashboard;
use Encore\Admin\Layout\Column;
use Encore\Admin\Layout\Content;
use Encore\Admin\Layout\Row;
use Encore\Admin\Widgets\InfoBox;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
class QrcodeController extends Controller
{
    protected $title = '推广二维码';
    
    public function index(Content $content)
    {
        return $content
            ->title('推广二维码')
            ->row(function (Row $row) {
                $auth = Auth::guard('admin')->user()->toArray();//获取后端登录用户信息
                $user_info = DB::table('users')->where(['account'=> $auth['account']])->first();
                if( $user_info ){
                    $h5_index = env('APP_URL') . "/h5";
                    $basic_url = $h5_index."?first_uid=".$user_info->id;
                }else{
                    $h5_index = env('APP_URL') . "/h5";
                    $basic_url = $h5_index;
                }
                if($auth['qr_code'])
                {
                    $row->column(12, '<div style="text-align: center"><p style="font-size: 26px">二维码链接：'.$basic_url.'</p></div>');
                    $row->column(12, '<div style="text-align: center"><img src="'.$auth['qr_code'].'" width="400" height="600"/></div>');
                }

            });
    }
}


